<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>JavaScript 创建 HTML 内容</title>
</head>
<script lang="JavaScript">
    function test() {
        var arr = new Array();
        arr[0] = '计算机科学与技术';
        arr[1] = '软件工程';
        arr[2] = '自动化';
        arr[5] = '物联网工程';
        var s = "";
        s += "<ul>";
        for (v in arr) {
            s += "<li>" + arr[v] + "</li>\n";
        }
        s += "</ul>";
        document.getElementById("show").innerHTML = s;
    }
</script>

<body>
    <div id="show"></div><br>
    <button onclick="test()">点击我</button>
</body>

</html>